package com.jboost.hyk.common.constant;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.jboost.common.constant.CommonConstant;
import com.jboost.common.constant.EnumInterface;

public enum CategoryGradeEnum implements EnumInterface {
    GRADE_0("grade_0", "类目",0),
    GRADE_1("grade_1", "一级分类",1),
    GRADE_2("grade_2", "专业",2);

    CategoryGradeEnum(String code, String desc, Integer intVal) {
        this.code = code;
        this.value = desc;
        this.desc = desc;
        this.intVal = intVal;
    }

    @EnumValue
    @JsonValue    //标记响应json值
    private final String code;
    private final String value;
    private final String desc;
    private final Integer intVal;

    public String getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    public Integer getIntVal() {
        return intVal;
    }

    public static CategoryGradeEnum getByCode(String code) {
        CategoryGradeEnum[] enums = CategoryGradeEnum.values();
        for (int i = 0; i < enums.length; i++) {
            if(enums[i].code.equals(code)){
                return enums[i];
            }
        }
        return null;
    }
    public static String getValueByCode(String code) {
        CategoryGradeEnum status = CategoryGradeEnum.getByCode(code);
        if(null == status){
            return CommonConstant.UNDIFIND_DEFALUT;
        }
        return status.getValue();
    }
    public static String getDescByCode(String code) {
        CategoryGradeEnum status = CategoryGradeEnum.getByCode(code);
        if(null == status){
            return CommonConstant.UNDIFIND_DEFALUT;
        }
        return status.getDesc();
    }

    @Override
    public String desc() {
        return this.desc;
    }

    @Override
    public Integer value() {
        return null;
    }

    @Override
    public String code() {
        return this.code;
    }


}
